public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
    /**
     * 外观数列
     * @param n
     * @return
     */
    public static String countAndSay(int n) {
        String res="1";
        for(int i=2;i<=n;i++){
            StringBuilder str=new StringBuilder();
            for(int left=0,right=0;right<res.length();){
                while(right<res.length()&&res.charAt(left)==res.charAt(right)){
                    right++;
                }
                int count=right-left;
                str.append(count);
                str.append(res.charAt(left));
                left=right;
            }
            res=str.toString();
        }
        return res;
    }

    /**
     * N字形变换
     * @param s
     * @param numRows
     * @return
     */
    public static String convert(String s, int numRows) {
        if(numRows==1) return s;
        int n=s.length();
        int num=numRows*2-2;
        StringBuilder str=new StringBuilder();
        for(int i=0;i<n;i+=num){
            str.append(s.charAt(i));
        }
        for(int k=1;k<numRows-1;k++){
            for(int i=k,j=num-i;i<n||j<n;i+=num,j+=num){
                if(i<n) str.append(s.charAt(i));
                if(j<n) str.append(s.charAt(j));
            }
        }
        for(int i=numRows-1;i<n;i+=num){
            str.append(s.charAt(i));
        }
        return str.toString();
    }
}